package csu.ssd.student;

import csu.ssd.student.Dao.studentDao;
import csu.ssd.student.vo.Student;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;

import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;

public class gaiController implements Initializable {

    @FXML
    private ComboBox<String> shijian;

    @FXML
    private TableView<Student> cha;
    @FXML
    private TableColumn<Student,String> kemu;

    @FXML
    private TableColumn<Student, Integer> last;

    @FXML
    private TableColumn<Student, Integer> hao;

    @FXML
    private TableColumn<Student, Integer> jige;


    @FXML
    private TableColumn<Student, Integer> fen;

    private ObservableList<Student> RoleData = FXCollections.observableArrayList();

    @FXML
    void gai(ActionEvent event) {
        cha.getItems().clear();
        studentDao m=new studentDao();
        List<Student> list= m.getRole();
        int mm=1;
        for (Student f : list) {

            if ( shijian.getValue().equals(f.getShi()))
            {
             RoleData.add(f);

            //finishtowait.setCellValueFactory(cellData ->cellData.getValue().cb.getCheckBox());
            kemu.setCellValueFactory(new PropertyValueFactory<>("kemu"));
            last.setCellValueFactory(new PropertyValueFactory<>("last"));
            fen.setCellValueFactory(new PropertyValueFactory<>("fen"));
            jige.setCellValueFactory(new PropertyValueFactory<>("jige"));
          //  finishren.setCellValueFactory(new PropertyValueFactory<>("name"));
                cha.setItems(RoleData);

            }
        }




    }
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        shijian.getItems().addAll("大一上", "大一下", "大二上", "大二下", "大三上","大三下","大四上","大四下");


    }
}
